layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;


    /*表单Submit监听*/
    form.on("submit(addOrUpdateCusDevPlan)", function (data) {
       var index = top.layer.msg('数据提交中，请稍候', {
           icon: 16,
           time: false,
           shade: 0.8
       });
        //弹出loading
        //var url=ctx + "/cus_dev_plan/save";



        var formData = data.field;

        var url=ctx + "/cus_dev_plan/add"

        //判断计划项ID是否为空
        if ($('[name="id"]').val()) {
            url = ctx + "/cus_dev_plan/update";
        }


        $.post(url, formData, function (result) {

            //判断操作是否执行成功
            if (result.code == 200) {
               //成功
                //提示成功
                top.layer.msg("操作成功!",{icon:6});
                //关闭加载层
                top.layer.close(index);
                //关闭弹出层
                layer.closeAll("iframe");
                //刷新父窗口
                parent.location.reload();
            } else {
               //失败
                layer.msg(result.msg,{icon:5});
            }
        });
        return false;
    });



    /**
     * 关闭弹出层
     */
    $("#closeBtn").click(function () {
        //当在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name);//先得到当前iframe层的索引
        parent.layer.close(index);  //再执行关闭
    });




});